<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div class="d1">这是d1</div>
    <button onclick="setAttr()">设置属性</button>
    <button onclick="setTitle()">设置标题属性</button><br>
    <a id="a1">超链接</a>
</body>
<script>
   let dom=document.querySelector(".d1");
   let a=document.querySelector("#a1")
   console.log("div",dom.tagName);
   function setAttr(){
    a.setAttribute("href","https://www.baidu.com");
   }
   function setTitle(){
    a.setAttribute("title","BaiDu");
   }
   dom.title="div";

</script>
</html>